<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改分区</title>
    <link rel="stylesheet" th:href="@{/css/base.css}" media="all">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script type="text/javascript" th:src="@{/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/js/jquery-3.2.0.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/base.js}"></script>
    <style>
        body {
            overflow-y: auto;
            margin: 15px 0 15px 0;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <form class="layui-form" style="margin: 0 auto; max-width: 800px" action="" lay-filter="formDemo">
            <div class="layui-form layuimini-form">
                <input type="hidden" name="id" th:value="${data.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label required">分区名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" lay-reqtext="请输入分区名称" placeholder="请输入" class="layui-input" th:value="${data.name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="saveBtn">
                            保存
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" th:inline="javascript">

    layui.use(['form', 'layer'], function () {
        const form = layui.form,
            layer = layui.layer;

        // 监听提交
        form.on('submit(saveBtn)', function (res) {
            const data = res.field;
            // 提交后台
            Asurplus.post({
                url: ctxPath + 'zone-info/update',
                data: JSON.stringify(data)
            }, () => {
                layer.msg('操作成功', {icon: 1});
                setTimeout(function () {
                    const windowIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(windowIndex);
                }, 1000)
            });
            return false;
        });
    });
</script>
</body>
</html>
